﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace IvyOrm
{
    /// <summary>
    /// Specifies additional column specific options for IvyOrm methods.
    /// </summary>
    [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
    public sealed class ColumnAttribute : Attribute
    {
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        [DebuggerHidden] //so simple don't need code coverage
        public ColumnAttribute()
        { }


        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        /// <param name="columnName">The name of the Column in the database. When Null will use the properties name.</param>
        [DebuggerHidden] //so simple don't need code coverage
        public ColumnAttribute(string columnName)
        {
            this.ColumnName = columnName;
        }

        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        /// <param name="columnName">The name of the Column in the database. When null will use the properties name.</param>
        /// <param name="databaseType">The target database type used in Insert, Updates and Deletes. When Null will use the type of the property (no conversion).</param>
        [DebuggerHidden] //so simple don't need code coverage
        public ColumnAttribute(string columnName, Type databaseType)
        {
            this.ColumnName = columnName;
            this.DatabaseType = databaseType;
        }

        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        /// <param name="columnName">The name of the Column in the database. When null will use the properties name.</param>
        /// <param name="databaseType">The target database type used in Insert, Updates and Deletes. When Null will use the type of the property (no conversion).</param>
        /// <param name="converterFactoryType">Overrides the default converter, type must be a valid ValueConverterFactory. When Null will use the default factory.</param>
        [DebuggerHidden] //so simple don't need code coverage
        public ColumnAttribute(string columnName, Type databaseType, Type converterFactoryType)
        {
            this.ColumnName = columnName;
            this.DatabaseType = databaseType;
            this.ConverterFactoryType = converterFactoryType;
        }

        /// <summary>
        /// The name of the Column in the database. When null will use the properties name.
        /// </summary>
        public string ColumnName { get; private set; }

        /// <summary>
        /// The target database type used in Insert, Updates and Deletes. When Null will use the type of the property (no conversion).
        /// </summary>
        public Type DatabaseType { get; private set; }

        /// <summary>
        /// Overrides the default converter, type must be a valid ValueConverterFactory. When Null will use the default factory.
        /// </summary>
        public Type ConverterFactoryType { get; private set; }
    }
}
